package com.trg.designmodel.flyweight;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @ClassName: WebSiteFactory
 * @Description:
 * @Author: tangrg
 * @Date: 2021/7/8 11:46
 * @Version: 1.0
 * @Return:
 **/
public class WebSiteFactory {
    Map<String, ConcreteWebSite> pool = new ConcurrentHashMap<>();


    public WebSite getWebSite(String type) {

        if (pool.get(type) == null) {
            pool.put(type, new ConcreteWebSite(type));
        }
        return pool.get(type);
    }

    public int getSize(){
        return pool.size();
    }
}
